/**
 * TransactionProperties.java 2017年02月20日 16:53
 * <p/>
 * Copyright (c) 2010-2016 yinghezhong Inc. All rights reserved.
 *
 * @Description
 * @version 1.0
 */
package com.ql.cloud.framework.config.dao.config.datasource;

import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 事务aop方法配置
 *
 * @author 齐龙
 * @date 2017年02月20日 16:53
 */
@Component
@ConfigurationProperties(prefix="tx")
public class TransactionProperties {
    private Map<String, String> attributes;
    private String pointCut;
    private Properties properties;

    public Properties getProperties() {
        if (properties == null){
            properties = new Properties();
            properties.put("*","PROPAGATION_REQUIRED");
            Set<Map.Entry<String, String>> entries = attributes.entrySet();
            Iterator<Map.Entry<String, String>> iterator = entries.iterator();
            while (iterator.hasNext()) {
                Map.Entry<String, String> entry = iterator.next();
                properties.put(entry.getKey(), entry.getValue());
            }
        }

        return properties;
    }

    public Map<String, String> getAttributes() {
        return attributes;
    }

    public void setAttributes(Map<String, String> attributes) {
        this.attributes = attributes;
    }

    public String getPointCut() {
        return pointCut;
    }

    public void setPointCut(String pointCut) {
        this.pointCut = pointCut;
    }
}
